package com.qd.common.sys.domain.entity.log;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

/**
 * 登录日志
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
public class LoginLogDTO extends BaseQuery {

    @ExcelIgnore
    @JsonIgnore
    private static final String EXCEL_TITLE="登录日志";
    /**
     * 主键
     */
    @ExcelProperty(value = {EXCEL_TITLE, "日志ID"})
    @NotBlank(message = "日志ID不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "日志ID长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    private String logId;
    /**
     * 用户ID
     */
    @ExcelProperty(value = {EXCEL_TITLE,"用户ID"})
    @Size(max = 50, message = "用户ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String userId;
    /**
     * 用户姓名
     */
    @ExcelProperty(value = {EXCEL_TITLE,"用户姓名"})
    @Size(max = 200, message = "用户姓名长度不能超过{max}位", groups = DefaultGroup.class)
    private String userName;
    /**
     * 账号
     */
    @ExcelProperty(value = {EXCEL_TITLE,"账号"})
    @NotBlank(message = "账号不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "账号长度不能超过{max}位", groups = DefaultGroup.class)
    private String account;
    /**
     * 机构ID
     */
    @ExcelProperty(value = {EXCEL_TITLE,"机构ID"})
    @NotBlank(message = "机构ID不能为空", groups = DefaultGroup.class)
    @Size(max = 50, message = "机构ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String orgId;
    /**
     * 机构名称
     */
    @ExcelProperty(value = {EXCEL_TITLE,"机构名称"})
    @Size(max = 100, message = "机构名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String orgName;
    /**
     * IP地址
     */
    @ExcelProperty(value = {EXCEL_TITLE,"IP地址"})
    @Size(max = 20, message = "IP地址长度不能超过{max}位", groups = DefaultGroup.class)
    private String userIp;
    /**
     * 浏览器
     */
    @ExcelProperty(value = {EXCEL_TITLE,"浏览器"})
    @Size(max = 50, message = "浏览器长度不能超过{max}位", groups = DefaultGroup.class)
    private String browser;
    /**
     * 操作系统
     */
    @ExcelProperty(value = {EXCEL_TITLE,"操作系统"})
    @Size(max = 50, message = "操作系统长度不能超过{max}位", groups = DefaultGroup.class)
    private String os;
    /**
     * 登录状态
     */
    @ExcelProperty(value = {EXCEL_TITLE,"登录状态"})
    @NotBlank(message = "登录状态不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "登录状态长度不能超过{max}位", groups = DefaultGroup.class)
    private String status;
    /**
     * 说明
     */
    @ExcelProperty(value = {EXCEL_TITLE,"说明"})
    @Size(max = 50, message = "说明长度不能超过{max}位", groups = DefaultGroup.class)
    private String message;
    /**
     * 访问时间
     */
    @ExcelProperty(value = {EXCEL_TITLE,"访问时间"})
    @NotNull(message = "访问时间不能为空", groups = DefaultGroup.class)
    private LocalDateTime loginTime;
@Override
    public void freeData() {
        this.logId = null;
        this.userId = null;
        this.userName = null;
        this.account = null;
        this.userIp = null;
        this.browser = null;
        this.os = null;
        this.status = null;
        this.message = null;
        this.loginTime = null;
        this.orgName = null;
        this.orgId = null;
        super.freeData();
    }
}
